package com.icehelper.hades.base.exception;


/**
 * 携带IErrorCode的公共异常。
 */
public class HadesErrorCodeException extends HadesBaseException{

  private static final long serialVersionUID = 4628232365423327231L;

  private IErrorCode errorCode = CommonErrorCode.SERVER_ERROR;

  public HadesErrorCodeException(IErrorCode errorCode) {
    this.errorCode = errorCode;
  }

  public HadesErrorCodeException(String message) {
    super(message);
  }

  public HadesErrorCodeException(String message,
      IErrorCode errorCode) {
    super(message);
    this.errorCode = errorCode;
  }

  public HadesErrorCodeException(String message, Throwable cause) {
    super(message, cause);
  }

  public HadesErrorCodeException(String message, Throwable cause,
      IErrorCode errorCode) {
    super(message, cause);
    this.errorCode = errorCode;
  }

  public HadesErrorCodeException(Throwable cause,
      IErrorCode errorCode) {
    super(cause);
    this.errorCode = errorCode;
  }

  public HadesErrorCodeException(String message, Throwable cause, boolean enableSuppression,
      boolean writableStackTrace, IErrorCode errorCode) {
    super(message, cause, enableSuppression, writableStackTrace);
    this.errorCode = errorCode;
  }

  public IErrorCode getErrorCode() {
    return errorCode;
  }

  @Override
  public String getLocalizedMessage() {
    String msg = this.errorCode == null ? CommonErrorCode.SERVER_BUSY.toString() : this.errorCode.toString();
    msg += "|" + super.getLocalizedMessage();
    return msg;
  }
}
